{% extends base %}

{% block body %}
{% init file_type = "history" %}

<div class="card">
    <h3><a href="/note/{{current_note.id}}" class="link2">{{current_note.name}}</a> / {{T("History")}}</h3>
    <table class="table">
        <tr>
            <th>名称</th>
            <th>时间</th>
            <th>版本</th>
            <th>操作</th>
        </tr>

        {% for note in history_list %}
        <tr>
            <td>{{note.name}}</td>
            <td>{{note.mtime}}</td>
            <td>{{note.version}}</td>
            <td><button class="view-btn" data-version="{{note.version}}">查看</button></td>
        </tr>
        {% end %}
    </table>
</div>

<script type="text/javascript">
$(function () {

    $(".view-btn").click(function (e) {
        var note_id = getUrlParam("id");
        var version = $(this).attr("data-version");
        var width   = $(".root").width() - 40;
        $.get("/note/history_view", {id: note_id, version: version}, function (resp) {
            layer.open({
                type:1, 
                shadeClose: true,
                title: "版本 - " + version,
                area: [width + "px", '80%'],
                content: $("<div>").append($("<textarea>").text(resp.data).width("100%").height("100%")).html()
            });
        }).fail(function (resp) {
            layer.alert("系统繁忙，请重试");
        });
    })

})
</script>

{% end %}

{% block aside %}
    {% include note/mod_aside.html %}
{% end %}
